// ==UserScript==
// @name         郑州大学远程教育全自动观看网课视频
// @namespace    好好学习天天向上
// @version      1.7
// @description  也许真的是终结版
// @author       壹局QQ639446649
// @match        http://ols.v.zzu.edu.cn/*
// @icon         https://gitee.com/yjgame-mark/autoPlayByZhengDa/raw/master/log.png
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js
// ==/UserScript==


(function () {
    'use strict';
    let dianboArr = []
    let record_now = 0
    setInterval(() => {
        let quxiao = $('.ant-modal-confirm-btns .ant-btn:first span')
        if (quxiao.length != 0) {
            quxiao.click()
            window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
        }
        let x = $('.ant-modal-content > button > span')
        if (x.length == 1) {
            x.click()
        }
        if ($('.videoErrorUrlListBox > .videoErrorUrlListTit').text() == '请尝试切换线路') {
            window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
        }
        let dianbo = $(".curriculumCard_headP2__2tuF1")
        if (dianbo.length != 0) {
            let fenshu = dianbo.find("span:first span")
            fenshu.each(function (index, element) {
                let difen = $(element).text().split("/")
                if (Number(difen[0]) < 10) {
                    dianboArr.push(fenshu[index])
                }
            });
            if (dianboArr.length != 0) {
                $(dianboArr[0]).click()
                dianboArr = []
            }
        }
        let iconClose = $(".video_TreePage__3sCrw > .ant-tree-treenode-switcher-close .ant-tree-switcher-icon");
        if (iconClose.length != 0) {
            iconClose.click()
        }
        let iconOpen = $(".video_TreePage__3sCrw > .ant-tree-treenode-switcher-open .ant-tree-switcher-icon");
        if (iconOpen.length != 0) {
            $(".video_start__2y2t5").each(function (index, element) {
                if ($(element).text() === "视频") {
                    if ($(element).next().text() !== "已完成" || $(element).next().length === 0) {
                        let play = $(".prism-progress-played")
                        if (play.length == 0) {
                            $(element).click();
                            return false
                        }
                    }

                }
            });
        }
        let current = $(".current-time")
        let duration = $(".duration")
        if (current.length > 0) {
            let nowArr = current.text().split(":")
            let endArr = duration.text().split(":")
            let now, end
            if (nowArr.length == 3) {
                now = Number(nowArr[0]) * 3600 + Number(nowArr[1]) * 60
                // console.log('时now', now);
            } else {
                now = Number(nowArr[0]) * 60 + Number(nowArr[1])
                // console.log('分now', now);
            }
            if (endArr.length == 3) {
                end = Number(endArr[0]) * 3600 + Number(endArr[1]) * 60
                // console.log('时end', end);
            } else {
                end = Number(endArr[0]) * 60 + Number(endArr[1])
                // console.log('分end', end);
            }
            if (parseInt(now / end * 10) >= 8) {
                window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
            }
            
        }
    }, 2000);
})();


